// JavaScript Document

function startMove(obj,json,fn){
		
	clearInterval(obj.timer);
	obj.timer = setInterval(function(){
	
		var bBtn = true;
		
		for(var attr in json){
			
			var iCur = 0;
			if(attr == 'opacity'){
				iCur = Math.round(getStyle(obj,attr)*100);
			}
			else{
				iCur = parseInt(getStyle(obj,attr));
			}
			
			var iSpeed = (json[attr] - iCur)/6;
			iSpeed = iSpeed>0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
			
			if(iCur != json[attr]){
				bBtn = false;
			}
			
			if(attr == 'opacity'){
				obj.style.filter = 'alpha(opacity='+ (iCur+iSpeed) +')';
				obj.style.opacity = (iCur+iSpeed)/100;
			}
			else{
				obj.style[attr] = iCur + iSpeed + 'px';
			}
		
		}
		
		if(bBtn){
			clearInterval(obj.timer);
			if(fn){
				fn.call(obj);
			}
		}
		
		
	},30);
	
}

function getStyle(obj,attr){
	if(obj.currentStyle){
		return obj.currentStyle[attr];
	}
	else{
		return getComputedStyle(obj,false)[attr];
	}
}
function getByClass(sClass,parent){
		
	var aEles=(parent||document).getElementsByTagName('*');
	var arr=[];
	
	for(var i=0;i<aEles.length;i++){
	
		aClass=aEles[i].className.split(' ');// aEles里面存的是例如li，ul等等节点。
		for(var j=0;j<aClass.length;j++){
		
			if(aClass[j]==sClass){
			
				arr.push(aEles[i]);// 存在数组中的类型是对象；
			}
		}
	}
	

	return arr;
}
function bindEvent(obj, sEv, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(sEv, fn, false);
	} else {
		obj.attachEvent('on'+sEv, function() {
			fn.call(obj);
		});
	}
}	
function viewW(){
	return document.documentElement.clientWidth;	
}

function viewH(){
	return document.documentElement.clientHeight;
}

function scrollX(){

	return 	document.body.scrollLeft || document.documentElement.scrollLeft;
	
}

function scrollY(){

	return 	document.body.scrollTop || document.documentElement.scrollTop;

}

function scrollH(){
	return document.body.scrollHeight;	
}